package nccloud.impl.arap.txdj.backgroundtask;

import java.io.PrintWriter;
import java.io.StringWriter;

import nc.bs.fmr.util.ExceptionUtils;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.pa.PreAlertReturnType;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.MultiLangText;
import nccloud.itf.arap.amortization.aggamortizationvo.IAmortizationvoService; 
public class GenVoucherTask implements IBackgroundWorkPlugin {

	@Override
	public PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {
		MultiLangText text = new MultiLangText();
		PreAlertObject pao = new PreAlertObject();
		pao.setReturnType(PreAlertReturnType.RETURNNOTHING);
		pao.setReturnObj(text);  
		try {
			NCLocator.getInstance().lookup(IAmortizationvoService.class).genVoucher();
		} catch (Exception e) {
			e.printStackTrace();
			throw new BusinessException(getStackTrace(e));
			
		}
		return pao;  
	}
	
	public  String getStackTrace(Throwable t) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		try {
			t.printStackTrace(pw);
			return sw.toString();
		} finally {
			pw.close();
		}
	}
}
